package io.web.gateway.rpc;

import io.web.utils.BaseResponse;
import io.web.utils.R;
import io.web.vo.interfaceinfo.InterfaceInfo;
import io.web.vo.interfaceinfo.InterfaceInfoQueryRequest;
import io.web.vo.interfaceinfo.User;
import io.web.vo.interfaceinfo.UserAccessRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * AdminService.
 * feign调用接口
 *
 * @date 2023-06-02
 */
@FeignClient(name = "${rpc.name}", url = "${rpc.url}")
public interface AdminService {

    /**
     * 通过url和method获取接口信息
     * @param interfaceInfoQueryRequest
     * @return
     */
    @PostMapping("/interfaceInfo/findInterfaceInfo")
    InterfaceInfo findInterfaceInfo(@RequestBody InterfaceInfoQueryRequest interfaceInfoQueryRequest);

    /**
     * 增加调用次数  RequestParam.value() was empty on parameter 0,必须添加参数名称
     * @param userId
     * @param interfaceId
     * @return
     */
    @GetMapping("/userInterfaceInfo/updateTimes")
    R<Boolean> updateTimes(@RequestParam("userId") Long userId, @RequestParam("interfaceId") Long interfaceId);

    /**
     * 通过AK获取用户信息，rpc解耦
     * @param userAccessRequest
     * @return
     */
    @PostMapping("/user/getUserByAccessKey")
    User getUserByAccessKey(@RequestBody UserAccessRequest userAccessRequest);
}
